{% extends "layouts/base.html" %}
{% load i18n admin_urls static admin_modify %}

{% block extrahead %}
    {{ block.super }}
    <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
    {{ media }}
{% endblock %}

{% block extrastyle %}
    <link rel="stylesheet" type="text/css" href="{% static "assets/css/forms.css" %}">
{% endblock %}

{% if not is_popup %}
    {% block breadcrumbs %}
        <div class="page-header">
            <div class="page-block">
              <div class="row align-items-center">
                <div class="col-md-12">
                  <div class="page-header-title">
                    <h5 class="m-b-10">{{ opts.verbose_name_plural|capfirst }}</h5>
                  </div>
                  <ul class="breadcrumb">
                    <li class="breadcrumb-item"><a href="#"><i class="feather icon-home"></i></a></li>
                    <li class="breadcrumb-item"><a href="javascript:">{{ opts.app_config.verbose_name }}</a></li>
                    <li class="breadcrumb-item"><a href="javascript:">{{ opts.verbose_name_plural|capfirst }}</a></li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
    {% endblock %}
{% endif %}

{% block content %}
<div class="container-fluid py-2">
    <div class="py-4 ms-4">
        <div class="d-flex justify-content-between w-100 flex-wrap">
            <div class="mb-3 mb-lg-0">
                 <h1 class="h4">
                     {% if add %}
                        {% blocktrans with name=opts.verbose_name %}Add {{ name }}{% endblocktrans %}
                     {% else %}
                        {{ original|truncatewords:"18" }}
                     {% endif %}
                 </h1>
            </div>
            <div>
                {% block object-tools %}
                    {% if change %}{% if not is_popup %}
                        {% block object-tools-items %}
                            {% change_form_object_tools %}
                        {% endblock %}
                    {% endif %}{% endif %}
                {% endblock %}
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-12 mb-4">
            <div class="card">
                <div class="card-body">
                    <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}"
                          method="post" id="{{ opts.model_name }}_form" novalidate>

                        {% csrf_token %}
                        <div class="{{ direction.panel }}">{% block form_top %}{% endblock %}</div>
                        <div>
                            {% block field_sets %}
                                {% for fieldset in adminform %}
                                    {% if forloop.counter > 1 %}<hr>{% endif %}
                                    {% include "admin/includes/fieldset.html" %}
                                {% endfor %}
                            {% endblock %}

                            {% block after_field_sets %}{% endblock %}

                            {% block inline_field_sets %}
                                {% for inline_admin_formset in inline_admin_formsets %}
                                    {% include inline_admin_formset.opts.template %}
                                {% endfor %}
                            {% endblock %}

                            {% block after_related_objects %}{% endblock %}

                            {% block submit_buttons_bottom %}{% submit_row %}{% endblock %}

                            {% block admin_change_form_document_ready %}
                                <script type="text/javascript"
                                        id="django-admin-form-add-constants"
                                        src="{% static 'admin/js/change_form.js' %}"
                                        {% if adminform and add %}
                                        data-model-name="{{ opts.model_name }}"
                                        {% endif %}>
                                </script>
                            {% endblock %}

                            {% prepopulated_fields_js %}

                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
